<?php
class Sfs_Controller_Plugin_Ssl extends Zend_Controller_Plugin_Abstract

{
    protected $_ssl;

    public function __construct($enabled = true)
    {
        $this->_ssl = (BOOL) $enabled;
    }

    public function preDispatch($action)
    {
        if ($this->_ssl) {

            if (!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) != 'on') {
                header('Location: https://' . $_SERVER['SERVER_NAME']
                . $_SERVER['REQUEST_URI']);
                exit;
            }
        }
        return $action;
    }
}